#pragma once
#include "../lua/ELuna.h"
#include "../gge/ggebase.h"
#include "../gge/ggetexture.h"
#include "../gge/ggesprite.h"
#include <string>

using namespace std;
using namespace ELuna;
namespace gge { typedef guint32 gUInt; }
extern lua_State*	L ;
class LuaImage
{
public:
	LuaImage();
	~LuaImage();
	void    clear();
	bool	Image_LoadFile(const char * filename, gge::gUInt colorKey);
	bool	Image_LoadMem(UINT filename, ULONG size, UINT colorKey,const char *pfile);
	void	Render(float x, float y);
	bool	Lock(bool readOnly);
	UINT	GetPixel(int x, int y) ;
	void	SetPixel(int x, int y,UINT col);
	void	Unlock();
	void	SetRect(float x, float y, float width, float height);
	void	SetColor(gge::gUInt color);
	void	SetZ(float z) ;
	void	SetBlendMode(int blend);
	void	SetTextureFilter(bool b) ;
	void	SetFlip(bool bX,bool bY );
	//void	GetRect(float *x, float *y, float *width, float *height) = 0;
	UINT		GetColor() ;
	float		GetZ() ;
	int			GetBlendMode();
	bool		IsTextureFilter() ;
	LuaTable	GetFlip() ;
	int			GetWidth() ;
	int			GetHeight() ;
	UINT		GetP();
	void		SetP(UINT v ,const char *pfile);
	int			GetRefCount();
	void		AddRef();
	void		Release();
private:
	gge::ggeTexture* _texture = nullptr;
	gge::ggeSprite* _sprite = nullptr;
	gge::guint32* _datas = nullptr;
	string m_file;
	bool m_islock;
};